/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.com.remiseria.frame;

import ar.com.remiseria.bo.ClienteBO;
import ar.com.remiseria.bo.TipoDeDocumentoBO;
import ar.com.remiseria.entities.Cliente;
import ar.com.remiseria.entities.Documento;
import ar.com.remiseria.entities.Domicilio;
import ar.com.remiseria.entities.TipoDeDocumento;
import ar.com.remiseria.utils.PropertiesReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;

/**
 *
 * @author gdorrego
 */
public class EditarClienteFrame extends javax.swing.JFrame {

    private List<TipoDeDocumento> listaTipoDeDocumento = new ArrayList<TipoDeDocumento>();
    private Cliente clienteActual;

    /**
     * Creates new form AltaClienteFrame
     */
    public EditarClienteFrame(Cliente cliente) {
        initComponents();
        this.clienteActual = cliente;
        this.getAllTipoDeDocumento();
        this.getDatosDelClienteActual();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        nombreTxt = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        apellidoTxt = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        tipoDeDocumentoComboBox = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        nroDocumentoTxt = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        telefonoTxt = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        calleTxt = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        numeroTxt = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        pisoTxt = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        departamentoTxt = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        codPostalTxt = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        localidadTxt = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        provinciaTxt = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        observacionesTxt = new javax.swing.JTextField();
        volverBtn = new javax.swing.JButton();
        guardarClienteBtn = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        archivoMenuBtn = new javax.swing.JMenu();
        guardarClienteMenuBtn = new javax.swing.JMenuItem();
        volverMenuBtn = new javax.swing.JMenuItem();
        ayudaMenuBtn = new javax.swing.JMenu();
        acercaDeMenuBtn = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Alta Cliente");
        setForeground(java.awt.Color.green);
        setResizable(false);

        jLabel1.setText("Nombre*");

        nombreTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                nombreTxtKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                nombreTxtKeyTyped(evt);
            }
        });

        jLabel2.setText("Apellido*");

        apellidoTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                apellidoTxtKeyTyped(evt);
            }
        });

        jLabel3.setText("Tipo Documento*");

        jLabel4.setText("Nro documento*");

        nroDocumentoTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroDocumentoTxtActionPerformed(evt);
            }
        });
        nroDocumentoTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                nroDocumentoTxtKeyTyped(evt);
            }
        });

        jLabel5.setText("Telefono*");

        telefonoTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                telefonoTxtKeyTyped(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Domicilio"));

        jLabel6.setText("Calle*");

        jLabel7.setText("Numero");

        numeroTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                numeroTxtKeyTyped(evt);
            }
        });

        jLabel8.setText("Piso");

        pisoTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                pisoTxtKeyTyped(evt);
            }
        });

        jLabel9.setText("Departamento");

        jLabel10.setText("C.P.");

        codPostalTxt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                codPostalTxtKeyTyped(evt);
            }
        });

        jLabel11.setText("Localidad*");

        jLabel12.setText("Provincia*");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(provinciaTxt))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel6)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(calleTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel9)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(departamentoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(28, 28, 28)
                            .addComponent(jLabel10)
                            .addGap(2, 2, 2)
                            .addComponent(codPostalTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(numeroTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pisoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(localidadTxt)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(calleTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(numeroTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(pisoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(departamentoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(codPostalTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11)
                    .addComponent(localidadTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(provinciaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jLabel13.setText("Observaciones");

        volverBtn.setText("Volver");
        volverBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                volverBtnActionPerformed(evt);
            }
        });

        guardarClienteBtn.setText("Guardar cliente");
        guardarClienteBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarClienteBtnActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Dialog", 0, 10)); // NOI18N
        jLabel14.setText("Los campos con * son obligatorios.");

        archivoMenuBtn.setText("Archivo");

        guardarClienteMenuBtn.setText("Guardar cliente");
        guardarClienteMenuBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarClienteMenuBtnActionPerformed(evt);
            }
        });
        archivoMenuBtn.add(guardarClienteMenuBtn);

        volverMenuBtn.setText("Volver");
        volverMenuBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                volverMenuBtnActionPerformed(evt);
            }
        });
        archivoMenuBtn.add(volverMenuBtn);

        jMenuBar1.add(archivoMenuBtn);

        ayudaMenuBtn.setText("Ayuda");

        acercaDeMenuBtn.setText("Acerca de esta ventana");
        acercaDeMenuBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                acercaDeMenuBtnActionPerformed(evt);
            }
        });
        ayudaMenuBtn.add(acercaDeMenuBtn);

        jMenuBar1.add(ayudaMenuBtn);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(telefonoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tipoDeDocumentoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(apellidoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel1)))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(nroDocumentoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(nombreTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(observacionesTxt))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(guardarClienteBtn)
                                .addGap(18, 18, 18)
                                .addComponent(volverBtn)))
                        .addGap(33, 33, 33))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(nombreTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(apellidoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(nroDocumentoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(tipoDeDocumentoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(telefonoTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(observacionesTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(volverBtn)
                    .addComponent(guardarClienteBtn)
                    .addComponent(jLabel14))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void guardarClienteBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarClienteBtnActionPerformed
        this.guardarCliente();
    }//GEN-LAST:event_guardarClienteBtnActionPerformed

    private void volverBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_volverBtnActionPerformed
        this.irAABMClientes();
    }//GEN-LAST:event_volverBtnActionPerformed

    private void nombreTxtKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nombreTxtKeyPressed

    }//GEN-LAST:event_nombreTxtKeyPressed

    private void nombreTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nombreTxtKeyTyped
        if (!this.validarIfNotANumber(evt)) { // Entra si es un numero
            evt.consume();
        }
    }//GEN-LAST:event_nombreTxtKeyTyped

    private void apellidoTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_apellidoTxtKeyTyped
        if (!this.validarIfNotANumber(evt)) {
            evt.consume();
        }
    }//GEN-LAST:event_apellidoTxtKeyTyped

    private void nroDocumentoTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nroDocumentoTxtKeyTyped
        if (this.validarIfNotANumber(evt)) {
            evt.consume();
        }
    }//GEN-LAST:event_nroDocumentoTxtKeyTyped

    private void telefonoTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_telefonoTxtKeyTyped
        if (this.validarIfNotANumber(evt)) {
            evt.consume();
        }
    }//GEN-LAST:event_telefonoTxtKeyTyped

    private void numeroTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_numeroTxtKeyTyped
        if (this.validarIfNotANumber(evt)) {
            evt.consume();
        }
    }//GEN-LAST:event_numeroTxtKeyTyped

    private void pisoTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pisoTxtKeyTyped
        if (this.validarIfNotANumber(evt)) {
            evt.consume();
        }
    }//GEN-LAST:event_pisoTxtKeyTyped

    private void codPostalTxtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_codPostalTxtKeyTyped
        if (this.validarIfNotANumber(evt)) {
            evt.consume();
        }
    }//GEN-LAST:event_codPostalTxtKeyTyped

    private void guardarClienteMenuBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarClienteMenuBtnActionPerformed
        this.guardarCliente();
    }//GEN-LAST:event_guardarClienteMenuBtnActionPerformed

    private void acercaDeMenuBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acercaDeMenuBtnActionPerformed
        this.mostrarAyudaAltaCliente();
    }//GEN-LAST:event_acercaDeMenuBtnActionPerformed

    private void volverMenuBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_volverMenuBtnActionPerformed
        this.irAABMClientes();
    }//GEN-LAST:event_volverMenuBtnActionPerformed

    private void nroDocumentoTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroDocumentoTxtActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nroDocumentoTxtActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EditarClienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EditarClienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EditarClienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EditarClienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EditarClienteFrame(null).setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem acercaDeMenuBtn;
    private javax.swing.JTextField apellidoTxt;
    private javax.swing.JMenu archivoMenuBtn;
    private javax.swing.JMenu ayudaMenuBtn;
    private javax.swing.JTextField calleTxt;
    private javax.swing.JTextField codPostalTxt;
    private javax.swing.JTextField departamentoTxt;
    private javax.swing.JButton guardarClienteBtn;
    private javax.swing.JMenuItem guardarClienteMenuBtn;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField localidadTxt;
    private javax.swing.JTextField nombreTxt;
    private javax.swing.JTextField nroDocumentoTxt;
    private javax.swing.JTextField numeroTxt;
    private javax.swing.JTextField observacionesTxt;
    private javax.swing.JTextField pisoTxt;
    private javax.swing.JTextField provinciaTxt;
    private javax.swing.JTextField telefonoTxt;
    private javax.swing.JComboBox tipoDeDocumentoComboBox;
    private javax.swing.JButton volverBtn;
    private javax.swing.JMenuItem volverMenuBtn;
    // End of variables declaration//GEN-END:variables

    private void getAllTipoDeDocumento() {
        TipoDeDocumentoBO tipoDeDocBO = new TipoDeDocumentoBO();
        try {
            this.listaTipoDeDocumento = tipoDeDocBO.getAllTipoDeDocumento();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        if (this.listaTipoDeDocumento != null && !this.listaTipoDeDocumento.isEmpty()) {
            for (TipoDeDocumento tdd : listaTipoDeDocumento) {
                tipoDeDocumentoComboBox.addItem(tdd.getDescripcion());
            }
        }
    }

    private void guardarCliente() {
        String mensajeValidacion = this.validarCampos();
        if (!mensajeValidacion.equals("ok")) {
            JOptionPane.showMessageDialog(this, mensajeValidacion);
        } else {
            Domicilio domicilio = this.armarDomicilio();

            clienteActual.setNombre(nombreTxt.getText());
            clienteActual.setApellido(apellidoTxt.getText());
            clienteActual.setDomicilio(domicilio);
            clienteActual.setTelefono(telefonoTxt.getText());
            clienteActual.setDocumento(new Documento());
            int index = tipoDeDocumentoComboBox.getSelectedIndex();
            if (index > -1) {
                clienteActual.getDocumento().setTipoDeDocumento(listaTipoDeDocumento.get(index));
                clienteActual.getDocumento().setNumero(Long.valueOf(nroDocumentoTxt.getText()));
            }

            ClienteBO clienteBO = new ClienteBO();
            try {
                clienteBO.updateCliente(clienteActual);
                JOptionPane.showMessageDialog(this,
                        PropertiesReader.getInstance().getApplicationMessage("info.abm.cliente.guardadook"));
            } catch (Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(this, ex);
            }
        }
    }

    private String validarCampos() {
        if (nombreTxt.getText().length() == 0 || nombreTxt.getText().trim().equals("")) {
            return "El campo Nombre es obligatorio.";
        }
        if (apellidoTxt.getText().length() == 0 || apellidoTxt.getText().trim().equals("")) {
            return "El campo Apellido es obligatorio.";
        }
        if (nroDocumentoTxt.getText().length() == 0 || nroDocumentoTxt.getText().trim().equals("")) {
            return "El campo Nro Documento es obligatorio.";
        }
        if (calleTxt.getText().length() == 0 || calleTxt.getText().trim().equals("")) {
            return "El campo Calle es obligatorio.";
        }
        if (localidadTxt.getText().length() == 0 || localidadTxt.getText().trim().equals("")) {
            return "El campo Localidad es obligatorio.";
        }
        if (provinciaTxt.getText().length() == 0 || provinciaTxt.getText().trim().equals("")) {
            return "El campo Provincia es obligatorio.";
        }
        if (tipoDeDocumentoComboBox.getSelectedIndex() == -1) {
            return "El Tipo De Documento es obligatorio";
        }

        return "ok";
    }

    private Domicilio armarDomicilio() {
        Domicilio domicilio = new Domicilio();

        domicilio.setCalle(calleTxt.getText());
        domicilio.setNumero(Integer.valueOf(numeroTxt.getText()));
        if (pisoTxt.getText() != "" && pisoTxt.getText().length() > 0) {
            domicilio.setPiso(Integer.valueOf(pisoTxt.getText()));
        }
        domicilio.setDepartamento(departamentoTxt.getText());
        domicilio.setCodigoPostal(Integer.valueOf(codPostalTxt.getText()));
        domicilio.setLocalidad(localidadTxt.getText());
        domicilio.setProvincia(provinciaTxt.getText());
        return domicilio;
    }

    private void irAABMClientes() {
        ABMClientesFrame acf = new ABMClientesFrame();
        acf.setVisible(true);
        this.dispose();
    }

    private boolean validarIfNotANumber(java.awt.event.KeyEvent evt) {

        // Devuelve TRUE si no es un numero
        char c = evt.getKeyChar();
        if ((c >= '0' && c <= '9') || c == ','
                || c == '.'
                || c == '/'
                || c == '*'
                || c == '+'
                || c == '-') {
            return false;
        }
        return true;
    }

    private void mostrarAyudaAltaCliente() {

        String mensaje = PropertiesReader.getInstance().getApplicationMessage("ayuda.acerca.altaCliente");
        JOptionPane.showMessageDialog(this, mensaje);

    }

    private void getDatosDelClienteActual() {
        nombreTxt.setText(clienteActual.getNombre());
        apellidoTxt.setText(clienteActual.getApellido());

        short contador = 0;
        for (TipoDeDocumento tdd : listaTipoDeDocumento) {
            if (tdd.getCodigo().equals(clienteActual.getDocumento().getTipoDeDocumento().getCodigo())) {
                break;
            } else {
                contador++;
            }
        }
        tipoDeDocumentoComboBox.setSelectedIndex(contador);
        nroDocumentoTxt.setText(clienteActual.getDocumento().getNumero().toString());

        Domicilio dom = clienteActual.getDomicilio();
        calleTxt.setText(dom.getCalle());

        if (dom.getNumero() != null) {
            numeroTxt.setText(dom.getNumero().toString());
        }
        if (dom.getPiso() != null) {
            pisoTxt.setText(dom.getPiso().toString());
        }
        departamentoTxt.setText(dom.getDepartamento());
        if (dom.getCodigoPostal() != null) {
            codPostalTxt.setText(dom.getCodigoPostal().toString());
        }
        localidadTxt.setText(dom.getLocalidad());
        provinciaTxt.setText(dom.getProvincia());

        observacionesTxt.setText(clienteActual.getObservaciones());
        
        telefonoTxt.setText(clienteActual.getTelefono());
    }

}
